1. Field of the Invention
The present invention relates to an image coding apparatus and an image coding method. More particularly, the present invention relates to a technique used to improve coding efficiency of the image coding apparatus in a case where a correlation between pictures is lost.
2. Description of the Related Art
As techniques for high-efficiently coding images, coding methods such as Moving Picture Experts Group Phase 2 (MPEG-2) are established. Electronics manufacturers are now developing and commercializing image capturing apparatuses such as digital cameras, digital video cameras and DVD recorders that can record images using the MPEG-2 coding method. Under such circumstances, users can readily reproduce images using such apparatuses as for example, personal computers, or DVD players.
In the MPEG-2 coding method, in order to efficiently transmit or store bit streams obtained by coding, code amount control (i.e., compressing the data to a predetermined code amount) is generally performed. Now, with respect to the code amount control in the MPEG-2 coding method, Test Model 5 (TM5), which is a reference soft encoder, will be described as an example. The TM5 is described in “Test Model Editing Committee: “Test Model 5,” ISO/IEC, JTC/SC29/WG11/n0400 (April 1993).
The code amount control using the TM5 has following three steps. In the process of step 1, code amounts to be assigned to respective pictures in a group of pictures (GOP) are distributed to the pictures, based on a total code amount assignable to pictures that have not been coded in the GOP including the pictures to be assigned. This distribution process is repeatedly performed to coding target pictures in the GOP, in the order of coding.
In the process of step 2, in order to match the code amount assigned to each picture obtained in the above step 1 with an actually generated code amount, a following procedure is executed. That is, based on capacities of three types of virtual buffer units independently set for respective pictures I, P, and B, a quantization scale code is calculated performing feedback control for each macro-block.
In the process of step 3, at a flat portion where deterioration of the image is visually conspicuous, fine quantization is performed, and at a complicated pattern portion where deterioration is relatively inconspicuous, a rough quantization is performed. That is, the quantization scale obtained in step 2 is varied and determined using a variable called a normalized activity for each macro-block of 16×16 pixels.
The normalized activity calculation method and quantization scale determination method in step 3 will be described in detail below. A normalized activity representing the pattern complexity is calculated as follows: First, a macro-block of 16×16 pixels is divided into a total of eight blocks, (i.e., four 8×8 pixel blocks in a field discrete cosine transform mode, and four 8×8 pixel blocks in a frame discrete cosine transform mode). Then, an activity is calculated based on a variance value var_{sblk} of a luminance signal pixel value Pj of an original picture in each block. The variance value of 8×8 pixel block is calculated by:
                                                                        var_                ⁢                                  {                  sblk                  }                                            =                                                ∑                                      j                    =                    1                                    64                                ⁢                                                      (                                                                  P                        j                                            -                      P                                        )                                    2                                                                                                                                                                                                            (                              P                =                                                      1                    64                                    ⁢                                                            ∑                                              j                        =                        1                                            64                                        ⁢                                          P                      j                                                                                  )                                                          (        1        )            where P is an average pixel value of the luminance signal pixel values Pj of the 8×8 pixel blocks.
From among the total eight variance values calculated by equation (1), a minimum variance value is found and an activity is calculated according to the following equation (2). The minimum value of the variance value is used in equation (2) to perform fine quantization in a case where a flat portion exists in a macro-block, even if the portion constitutes only a part of the block.act=1+min(var—{sblk})  (2)
The activity value act calculated by the equation (2) increases if the image of interest has a complicated pattern, that is, the variance of the luminance signal pixel values is larger. On the other hand, the activity value act decreases if the image of interest is flat, that is, the variance of the luminance signal pixel values is smaller. Further, by the following equation (3), a normalized activity N_act is calculated so that the activity value falls within a range 0.5 to 2.0.N_act=(2×act+pred_avg_act)/(act+2×pred_avg_act)  (3)
In the average activity prediction method in TM5, a value of an average activity avg_act of a frame that is coded one frame before the coding target frame in a coding order is measured. The obtained value of an average activity avg_act is used as a predicted value of an average activity pred_avg_act of the coding target frames so as to perform normalization. Accordingly, significant variation of the normalization activity between the frames can be suppressed. If the activity is smaller than the average activity, the value of the normalization activity falls in the range 0.5 to 1.0. If the activity is larger than the average activity, the value falls in the range 1.0 to 2.0.
Based on the normalized activity N_act and the quantization scale code Qsc obtained in step 2, a quantization scale code MQUANT, in consideration of the visual characteristic according to the activity, is given by:MQUANT=Qsc×N_act  (4)
That is, in the case of the flat image whose normalized activity N_act is smaller, the quantization scale code MQUANT becomes smaller and the image is finely quantized. On the other hand, in the case of the image having complicated pattern, and whose normalized activity N_act is larger, the quantization scale code MQUANT increases and the image is roughly quantized. The code amount control using the TM5 method is performed by the above-described processes.
In order to improve the coding efficiency in the MPEG-2 coding method, various approaches have been made. For example, Japanese Patent Laid-Open No. 8-18952, discusses a technique for improving coding efficiency. According to Japanese Patent Laid-Open No. 8-18952, in order to obtain a predicted value of the average activity to be used in the above equation (3) for calculating a normalized activity, an average activity of a coding target frame is predicted from a measured value of average activity of coded frames other than the coding target frame. Then, based on the predicted value of the average activity, the normalized activity is calculated.
However, in the above-described conventional average activity prediction methods, the average activity of the coding target frame is predicted from the measured value of the average activity of the coded frames other than the coding target frame. Accordingly, in a case where a correlation between the frame to be coded and an immediately preceding and/or following frame, is lost due to a flash light, the average activity is not predictable. Therefore, the quantization control is not appropriately performed.